package main

import (
	"github.com/gin-gonic/gin"
	"github.com/spf13/pflag"
	"config"
	"github.com/spf13/viper"
	"router"
	"stores"
)

var (
	cfg = pflag.StringP("config", "c", "", "apiserver config file path.")
)

func main() {
	pflag.Parse()

	// init config
	if err := config.Init(*cfg); err != nil {
		//panic(err)
	}

	// init db
	stores.DB.InitMySql()
	defer stores.DB.Close()
	//init Redis
	stores.InitRedis()

	// Set gin mode.
	gin.SetMode(viper.GetString("runmode"))

	// Create the Gin engine.
	g := gin.New()

	router.Load(
		g,
	)
	g.Run()
}
